/*

package com.manger.chrome;

import com.manger.model.Dictionary_Data;
import com.manger.model.ProxyIp;
import com.manger.utils.DataTools;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.v139.network.Network;
import org.openqa.selenium.support.events.WebDriverListener;


*/
/**
 * @ClassName ChromeDriverListener
 * @Description TODO
 * @Author @LiuHongJun
 * @Date 2025-10-21 10:23
 * @Version 1.0
 *//*


public class ChromeDriverListener implements WebDriverListener {

    private int offset = 10;//偏移10秒

    private int periodTime = 3 * 60;

    private long lastTime = 0;

    private int index = 0;

    @Override
    public void beforeGet(WebDriver driver, String url) {

        if(DataTools.proxyIps == null || DataTools.proxyIps.size() == 0 || DataTools.proxyIps.size()  == index) {
            return;
        }

        //发起请求前处理ip代理问题
        ChromeDriver chromeDriver = (ChromeDriver) driver;
        long currentTime = System.currentTimeMillis();
        if (currentTime - lastTime > (periodTime - offset) * 1000) {
            //切换代理
            ProxyIp proxyIp = DataTools.proxyIps.get(index);
            String ssl = "https://" + proxyIp.getIp() + ":" + proxyIp.getPort();
            System.out.println(index + " : " + ssl);
            DevTools devTools = chromeDriver.getDevTools();
            devTools.createSession();
            index++;
        }
        lastTime = currentTime;
    }
}
*/
